package com.ttw.demo;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.ActivityManager;
import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.view.WindowManager;
import android.widget.TextView;

import com.blankj.utilcode.util.LogUtils;
import com.ttw.ttw.R;


@SuppressLint("WrongConstant")
public class ScreenLockActivityNew extends Activity {

    @SuppressLint("ObsoleteSdkInt")
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_back);
        TextView button = findViewById(R.id.bt_message);
        button.setText("TTW2 ScreenLockActivity2存活中。。。");
        addView();
    }

    private void addView() {
//        http://events.jianshu.io/p/7cfe49faf7df
        getWindow().setGravity(Gravity.CENTER);
//        WindowManager.LayoutParams layoutParams = getWindow().getAttributes();
//        layoutParams.flags = WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS |
//                WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL;
        getWindow().getAttributes().height =400;
        getWindow().getAttributes().flags = WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS |
                WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL;
//        getWindow().getAttributes().flags = 40;
        getWindow().getAttributes().dimAmount = 0.0f;
        dpfpkzmdxdxynlvp();
//        if (d2.getGravity() != Gravity.CENTER) {
//            this.x = new GestureDetector(this, new g());
//        }

    }


    public void dpfpkzmdxdxynlvp() {
        ActivityManager activityManager = null;
        if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) {
            activityManager = (ActivityManager) getSystemService("activity");
            if (activityManager != null) {
                for (ActivityManager.AppTask appTask : activityManager.getAppTasks()) {
                    ActivityManager.RecentTaskInfo taskInfo = appTask.getTaskInfo();
                    LogUtils.e("topActivity", taskInfo.topActivity.getClassName());
                    if (!(taskInfo == null || taskInfo.topActivity == null || !getClass().getName().equals(taskInfo.topActivity.getClassName()))) {

                        return;
                    }
                }
            }
        }

    }


    @Override
    protected void onResume() {
        super.onResume();
    }

    public void onClick(View view) {
        finish();
    }

    @Override
    protected void onStop() {
        super.onStop();

    }

    @Override
    protected void onPause() {
        super.onPause();

    }

    @Override
    protected void onDestroy() {
        super.onDestroy();

    }



}